<template>
	<view class='dispute-box'>
		<view class='card-box'>
			<view class='title'>争议处理流程</view>
			<view class='content-box'>
				<template v-for='(item,index) in options'>
					<view class='content-item' :key='index'>
						<view class='head'>
							<view class='num'>{{index+1}}</view>
						</view>
						<view class='bottom'>{{item}}</view>
					</view>
					<view class='content-item' v-if='index != options.length-1'>
						<view class='head'>
							<view class='icon'></view>
						</view>
						<view class='bottom'></view>
					</view>
				</template>
			</view>
		</view>
		
		<view class='form-box'>
			<view class='form-title'>请填写</view>
			<view class='form'>
				<view class='form-item'>
					<view class='label'>宠物认证编号</view>
					<view class="input-box">
						<input class='input' v-model='form.cargoNo' maxlength="10" placeholder="请输入宠物认证编号" placeholder-class='dispute-placeholder'></input>
					</view>
				</view>
				<view class='form-item'>
					<view class='label'>提交争议问题</view>
					<view class="input-box">
						<textarea class='input' v-model='form.title' disable-default-padding auto-height placeholder="请输入争议问题描述" placeholder-class='dispute-placeholder'></textarea>
					</view>
				</view>
				<view class='form-item'>
					<view class='label'>联系人</view>
					<view class="input-box">
						<input class='input' v-model='form.linker' maxlength="20" placeholder="请输入联系人姓名" placeholder-class='dispute-placeholder'></input>
					</view>
				</view>
				<view class='form-item'>
					<view class='label'>联系电话</view>
					<view class="input-box">
						<input class='input' v-model='form.linkphone'  maxlength="11" placeholder="请输入联系方式" placeholder-class='dispute-placeholder'></input>
					</view>
				</view>
				
				<view class='submit' @click='handleSubmit'>提交</view>
			</view>
		</view>
	</view>
</template>

<script>
	import regRules from '@/common/rules'
	import {addDispute} from '@/api/pet/dispute/index'
	export default {
		data() {
			return {
				options: ['争议问题','平台争议处理','专家问题评判','结果公示'],
				form: {}
			}
		},
		methods: {
			reset() {
				this.form = {
					cargoNo: undefined,
					title: undefined,
					linker: undefined,
					linkphone: undefined
				}
			},
			handleSubmit() {
				if(!this.form.cargoNo) return uni.showToast({title: '请输入宠物认证编号',icon: 'none'})
				if(!this.form.title) return uni.showToast({title: '请输入争议问题描述',icon: 'none'})
				if(!this.form.linker) return uni.showToast({title: '请输入联系人姓名',icon: 'none'})
				if(!this.form.linker) return uni.showToast({title: '请输入联系方式',icon: 'none'})
				if(!regRules.phone.test(this.form.linkphone)) return uni.showToast({title: '手机号格式不正确',icon: 'none'})
				addDispute(this.form).then(res => {
					this.reset()
					uni.showToast({title: '您好，您的问题已经提交',icon: 'none'})
				})
			}
		}
	}
</script>

<style>
	.dispute-placeholder {
		color: #BBBBBB;
	}
</style>
<style scoped lang="scss">
	.dispute-box {
		background: linear-gradient( 180deg, #FFFFFF 0%, #F8F8F8 100%);
		padding: 0 16rpx;
	}
	
	.card-box {
		width: 100%;
		background: linear-gradient( 180deg, #FFF6E5 0%, #FFFCF7 100%);
		border-radius: 16rpx;
		border: 2rpx solid #FFFFFF;
		
		.title {
			font-size: 30rpx;
			color: var(--h1Color);
			line-height: 42rpx;
			padding: 24rpx 0 32rpx 24rpx;
		}
		
		.content-box {
			width: 100%;
			padding:  0 42rpx 32rpx 42rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			
			.content-item {
				.head {
					height: 40rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					
					.num {
						width: 36rpx;
						height: 36rpx;
						background: var(--statusBg4);
						font-size: 26rpx;
						color: #fff;
						display: flex;
						align-items: center;
						justify-content: center;
						border-radius: 50%;
					}
					
					.icon {
						width: 0;
						height: 0;
						border: 8rpx  solid transparent;
						border-left-color: #EEDCBB;
					}
				}
				
				.bottom {
					margin-top: 12rpx;
					text-align: center;
					font-size: 24rpx;
					color: var(--btnColor);
					line-height: 33rpx;
					height: 33rpx;
				}
			}
		}
	}
	
	.form-box {
		padding-top: 32rpx;
		padding-bottom: 32rpx;
		
		.form-title {
			font-weight: 600;
			font-size: 34rpx;
			color: var(--btnColor);
			display: flex;
			align-items: center;
			
			&:before {
				content: '';
				display: block;
				width: 8rpx;
				height: 32rpx;
				background: var(--primaryBg);
				border-radius: 9rpx;
				margin-right: 8rpx;
			}
		}
		
		.form {
			margin-top: 24rpx;
			background: #FFFFFF;
			border-radius: 32rpx;
			padding: 0 24rpx 32rpx 24rpx;
			
			.form-item {
				display: flex;
				padding: 40rpx 0;
				border-bottom: 2rpx solid #EEEEEE;
				
				.label {
					font-weight: 600;
					font-size: 30rpx;
					color: var(--h1Color);
					line-height: 42rpx;
					margin-right: 20rpx;
				}
				
				.input-box {
					flex: 1;
					
					.input {
						width: 100%;
						font-size: 30rpx;
						text-align: right;
					}
				}
			}
			
			.submit {
				margin-top: 64rpx;
				width: 100%;
				height: 96rpx;
				background: var(--primaryBg);
				border-radius: 48rpx;
				font-weight: 600;
				font-size: 32rpx;
				color: var(--btnColor);
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}
</style>